//
//  MeetYouCell.swift
//  btvideo
//
//  Created by mac on 2020/6/18.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit
import SwiftyJSON
import SwiftyAttributes


//MARK: - Model




class ST_MeetYouCellModel : NSObject{

    var accid : String!
    var address : String!
    var avatar : String!
    /**最近访问时间*/
    var createInt : Int!
    var createTime : String!
    var distance : String!
    var faceAuditState : Int!
    var id : Int!
    var attentionId:Int!
    var lookNum : Int!
    var memberId : Int!
    var nickname : String!
    var state : Int!
    var targetMemberId : Int!
    var vdAddress : String!
    var vipExpire : Int!
    var sameCity:Bool
    var online_state:String
    var contentStr : String
    var subContentAttrStr = NSAttributedString()
    /**
     * Instantiate the instance using the passed json values to set the properties values
     */
    init(fromJson json: JSON,isLook:Bool = true){
        
        accid = json["accid"].stringValue
        online_state = json["online_state"].stringValue
        address = json["address"].stringValue
        avatar = json["avatar"].stringValue
        createInt = json["create_int"].intValue
        createTime = json["create_time"].stringValue
        distance = json["distance"].stringValue
        faceAuditState = json["face_audit_state"].intValue
        id = json["id"].intValue
        attentionId = json["attention_id"].intValue
        
        lookNum = json["look_num"].intValue
        memberId = json["member_id"].intValue
        nickname = json["nickname"].stringValue
        state = json["state"].intValue
        targetMemberId = json["target_member_id"].intValue
        vdAddress = json["vd_address"].stringValue
        vipExpire = json["vip_expire"].intValue
        sameCity = json["is_same_city"].boolValue
        
        if isLook{
            contentStr = "最近访问：" + createInt.double.b_t_global_date_string()
        }else{
            contentStr = ""
//            createInt.double.b_t_global_date_string()
//                + "对我点了喜欢"
        }
        
     
        
//        看我
        if isLook{
            
            let str = "看过你".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
            
            let number = lookNum.string.withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0xFEC207)!)])
            
            let suffixStr = "次".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
            
            str.append(number)
            
            str.append(suffixStr)
//            是同城
            if sameCity{
                
                let sameCityStr = "，你们是".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
                
                let sameCityMidStr = "同城".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0xFEC207)!)])
                
                let sameCitySuffixStr = "哦".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
                
                sameCityStr.append(sameCityMidStr)
                sameCityStr.append(sameCitySuffixStr)
                str.append(sameCityStr)
            }
            
            subContentAttrStr = str
            
        }else{
//            喜欢我 是同城
            if sameCity{
                
                let sameCityStr = "你们是".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
                
                let sameCityMidStr = "同城".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0xFEC207)!)])
                
                let sameCitySuffixStr = "哦".withAttributes([Attribute.font(UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)),.textColor(UIColor.init(hex: 0x333333)!)])
                
                sameCityStr.append(sameCityMidStr)
                sameCityStr.append(sameCitySuffixStr)
                subContentAttrStr = sameCityStr
            }
        }
        
        
        
    }
}
